package function

import "fmt"

func HighLeve() {
	s1 := student{firstName: "Naveen", lastName: "Ramanathan", grade: "A", country: "India"}
	s2 := student{firstName: "Samuel", lastName: "Johnson", grade: "B", country: "USA"}
	s := []student{s1, s2}
	f := filter(s, func(s student) bool {
		if s.grade == "B" {
			return true
		}
		return false
	})
	fmt.Println(f)
	fmt.Println("头等函数的实际用途示例1 ")
}

type student struct {
	firstName string
	lastName  string
	grade     string
	country   string
}

func filter(s []student, f func(student) bool) []student {
	var r []student
	for _, v := range s {
		if f(v) == true {
			r = append(r, v)
		}
	}
	return r
}
